function CategoryModel() {} 

CategoryModel = {
	createCategories: function(categories) {
		var arrCategories = [];
		var result = [];
		var category = null;

		arrCategories = categories.getElementsByTagName("category");
		for(var i=0;i<arrCategories.length; i++) {
			category = new Category(arrCategories[i].getElementsByTagName("categoryId")[0].childNodes[0].nodeValue, arrCategories[i].getElementsByTagName("categoryName")[0].childNodes[0].nodeValue);
			result.push(category);	
		}
		return result;
	},
	
	createBooks: function(books) {
		var arrBooks = [];
		var result = [];
		var book = null;


		arrBooks = books.getElementsByTagName("book");
		for(var i=0;i<arrBooks.length; i++) {
			book = new Book(arrBooks[i].getElementsByTagName("bookId")[0].childNodes[0].nodeValue, arrBooks[i].getElementsByTagName("picture")[0].childNodes[0].nodeValue, arrBooks[i].getElementsByTagName("bookName")[0].childNodes[0].nodeValue, arrBooks[i].getElementsByTagName("price")[0].childNodes[0].nodeValue);
			result.push(book);	
		}
		
		return result;
	}
};

var Category = function(categoryId,categoryName) {
	this.CategoryId= categoryId;
	this.CategoryName = categoryName;
}

var Book = function(id, pic, name, price){
	this.BookId = id;
	this.Pic = pic;
	this.Name= name;
	this.Price = price;
}

var ListBook = function(categories, books){
	this.Categories = categories;
	this.Books = books;
}
